package com.yungu.swift.order.thread.inform;

import com.fasterxml.jackson.databind.JsonNode;
import com.yungu.swift.utils.HttpUtils;
import com.yungu.swift.utils.JsonUtils;
import com.yungu.swift.utils.MapUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author : cuixiuyin
 * @date : 2020/1/7
 */
public class Test {

    public static void main(String[] args) {
        Map<String, String> paramsMap = new HashMap<>();
        Long timestamp = System.currentTimeMillis();
        paramsMap.put("client_id", "Cjcx");
        paramsMap.put("timestamp", timestamp.toString());
        paramsMap.put("order_id", "KC01120200107164902783");
        paramsMap.put("ext_order_id", "12144689761459773460B");
        paramsMap.put("event", "6");
        String sign = SHA1.encode(SignUtil.createSignStr(paramsMap));
        paramsMap.put("sign", sign);
        JsonNode jsonNode;
        try {
            jsonNode = JsonUtils.readNode(JsonUtils.toJSONString(paramsMap));
        } catch (Exception e) {
            return;
        }
        System.out.println("加密结果" + jsonNode);
        String callbackUrl = "https://apicloud.ccrgt.com/crgt/carhailing/callback/platform";
        Map<String, Object> resultMap = HttpUtils.post(callbackUrl, 3, MapUtils.build("_JSON_STRING", jsonNode.toString()), null, new HashMap<>());
        System.out.println("结果" + resultMap);
    }

}
